package com.example.about_netty.channelhandler;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;


public class SharableServerInitializer extends ChannelInitializer<Channel> {
    SharableMessageHandler handler = new SharableMessageHandler();

    @Override
    protected void initChannel(Channel channel) throws Exception {
//        Now that the state of the handler is attached to the ChannelHandlerContext
//         you can add the same handler instance to different pipelines
//         此时的context handler 犹如线程的私有栈数据 在自己的领域内 可以称王称霸
        channel.pipeline().addLast("messageHandler", handler);
    }
}
